home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Utilities / cronX10 1.0b6 folder / CronX10.docs next >
Encoding:
Text File  |  1994-09-03  |  11.3 KB  |  263 lines  |  [TEXT/R*ch]

  1.  
  2.  
  3. cronX10
  4.     
  5.     Version: 1.0b6
  6.     Date: September 3, 1994
  7.     Written by: Jerry Gatlin at Hill Country Softworks
  8.     
  9.     This program is copyrighted by the author and is not in the public
  10.     domain. I am offering this as freeware though, so you are able to
  11.     freely distribute this as long as this documentation accompanies
  12.     the application. You may freely use this in any non-commercial
  13.     manner. If you wish to use it in any other way, please contact the
  14.     author at:
  15.     
  16.       jerry@hipark.austin.isd.tenet.edu
  17.       
  18.       4702 Valley Oak Dr.
  19.       Austin, Texas 78731
  20.       512 458-1739
  21.       
  22.       Let me know how you like it and if it works as described.
  23.       
  24.     —————————————————————————————————————————————————————————————————————    
  25.     
  26. NAME
  27.         
  28.         cronX10 - a X10 controller (CP290) program to be used with Chris
  29.         Johnson's cron utility.
  30.         
  31.         
  32. DESCRIPTION
  33.  
  34.         This program controls X10 modules to turn on and off appliances,
  35.         lights, thermostats, and anything else that can be controlled by
  36.         X10 devices. This program requires a model CP290 X10 computer
  37.         interface along with the appropriate modules for the devices you
  38.         wish to control. X10 is available through a variety of sources and
  39.         both Radio Shack and Leviton make X10 components. Instead of having
  40.         to run wires to these modules to control them, the X10 protocol
  41.         runs over your existing AC wiring. You just plug in (or wire in)
  42.         the module and go.
  43.         
  44.         cronX10 solves a problem I've had for quite some time. The
  45.         application that came with my X10 light controller (CP290) was
  46.         written in the early days of the Macintosh when only MFS was
  47.         around. I finally got tired having to put everything at the root
  48.         level to run, and since I purchased a PowerMac I decided to write
  49.         the code myself.
  50.         
  51.         I'd been wanting to write a cron application for a while and this
  52.         seemed like a natural one. Since cron has a wonderful interface to
  53.         write an application to, and it already solved the scheduling
  54.         problem for me, I wrote this as a faceless bacground application to
  55.         be launched by cron.
  56.         
  57.         This means that YOU MUST HAVE CRON TO RUN THIS PROGRAM!!!
  58.  
  59.         Cron is a Macintosh version of the unix scheduling utility written
  60.         by Chris Johnson.  If you're unfamilar with the concept of cron,
  61.         please download cron and read its documentation before spending
  62.         much time with this documentation. You should be able to find cron
  63.         at most of the Mac archive sites. If you have trouble, try these
  64.         sites:
  65.         
  66.             anonymous ftp to ftp.cc.utexas.edu in the /pub/chrisj directory
  67.             the web page http://gargravarr.cc.utexas.edu/cron/cron.html
  68.             anonymous ftp to ftp.utexas.edu in the /pub/mac/util or
  69.             the web page http://www.utexas.edu/cc/microlib-mac/main.html   
  70.  
  71.         This has been tested with cron 1.0d16 which is the current version
  72.         as of August 29, 1994.
  73.         
  74.         As cron requires system 7 to run, this application by default
  75.         also requires system 7. Although the Comm ToolBox is built into
  76.         system 7, if for *any* reason Apple chooses to remove it at a later
  77.         time, this app won't work. It will be nice and report the reason
  78.         for its failure to you though.
  79.         
  80.         Although primarily intended for scheduling lights, etc. at
  81.         predetermined times, you can use Chris Johnson's "Command Line"
  82.         cron debugging aid for immediate, direct control of devices.
  83.         "Command Line" simply puts up a dialog and allows you to send
  84.         commands to cron applications immediately instead of setting up
  85.         cron to execute at the next minute and waiting for the minute to
  86.         roll by.
  87.         
  88.         Many thanks to Chris Johnson for writing cron and providing an
  89.         incredible interface to use when writing cron commands. And Chris,
  90.         thanks for the pointers on pointers and handles along with your
  91.         stringUtil functions, several of which I use in this code.
  92.         
  93.          This program is a fat binary (it runs native on either the PowerMac
  94.         or 68k Macs) and was written using the Metrowerks CodeWarrior C
  95.         Compiler.
  96.                 
  97.    —————————————————————————————————————————————————————————————————————
  98.  
  99. Change history:
  100.       
  101.       version 1.0b2 July 15, 1994
  102.         fixed a bug that hung in an infinite loop if CronX10 was launched by
  103.         double-clicking thru the finder. Also added an error message to the
  104.         log file to reflect this.
  105.  
  106.        version 1.0b3 July 19, 1994
  107.         Rewrote X10 routines to acknowledge ACK and event uploads. As a
  108.         result, we can get rid of the semi-heuristic timer that we were
  109.         using before to determine when we could send another event. I also
  110.         cleaned up the serial routines to include WaitNextEvent and a
  111.         timeout so that send and receive won't hang the system under any
  112.         condition. This includes a new routine that waits (with timeout)
  113.         for all characters to be sent through the serial port before
  114.         exiting.
  115.            
  116.        version 1.0b4 August 29, 1994
  117.            Added undocumented x10 direct commands to provide for:
  118.                 fade to off
  119.                relative bright
  120.         as identified by John Marvin and brought to my attention by Dick
  121.         Herring (thanks guys!). In the process I had changed my serial
  122.         routines to be more generic and moved all globals from
  123.         serialRoutines into main.
  124.  
  125.  
  126.        version 1.0b5 August 30, 1994
  127.         Changed ppc optimization so native would run in 34k. This had been
  128.         complied incorrectly so that memory had to be increased to 40k for
  129.         native version to run. Added blank lines between error messages in
  130.         error file. Made function parameters case insensitive.
  131.         Fixed a bad bug that would crash the machine if trying to access
  132.         a serial port that was already open. If port is open it will
  133.         now quit elegantly and write an error message in the log.
  134.            
  135.     version 1.0b6 September 3, 1994
  136.         Added -s argument to set the CP290's time to the Macintosh clock
  137.         Fixed bug that would cause cronX10 to hang if there was a
  138.         continuous stream of characters coming in the serial port. It
  139.         now times out after 15 seconds and reports the problem.
  140.         Added date and time to error log.
  141.         
  142.     —————————————————————————————————————————————————————————————————————
  143.  
  144. Usage:      cronX10 [-s][-l level]  [-f function] [-h housecode]
  145.                 [-u unit] [-p serialPort]
  146.             
  147. Purpose:    To control X10 lamp and applicance modules thru the CP290
  148.             X10 controller using cron to provide the scheduling service. 
  149.             
  150. Options:    -s    This option will syncronize the CP290's clock with
  151.                 the current Macintosh time. If this option is on
  152.                 the command line, all other options except -p are
  153.                 ignored. This allows you to periodically set the CP290
  154.                 clock to keep it accurate. This is particularly useful
  155.                 if you've downloaded timer events to the CP290 via
  156.                 another program and you wish to keep its clock accurate.
  157.                 
  158.             -l  Follow this with a number between 0 and 15 to control
  159.                 the level of a lamp (dimming) module. 15 is the brightest.
  160.                 If this option is not included, level will default
  161.                 to 15 (full bright).
  162.                 
  163.             -f  Follow this with one of these functions:
  164.             
  165.                     on (default)
  166.                         turns lamp module to full bright
  167.                         or appliance module to on.
  168.                      off
  169.                          turns lamp or appliance module off.
  170.                  
  171.                  These commands only work on lamp (dimmable) modules:
  172.                 
  173.                      dim
  174.                          turns lamp module to full bright and then
  175.                          dims to level set with -l option.
  176.                      
  177.                        fadeToOff
  178.                            fade any lamp module from its current setting
  179.                         to off. This is a nice effect. 
  180.                        
  181.                        relativeBright
  182.                         relativeBright does the opposite of fadeToOff-
  183.                         sort of... If your lamp module has been faded
  184.                         using dim to 0 (this WON'T quite turn your lamp
  185.                         all the way off) or if you've dimmed your lamp
  186.                         using a mini-controller or Leviton switch
  187.                         (which for some reason WILL let you dim to
  188.                         off!), then you can use this command with an
  189.                         appropriate level to increase the brightness.
  190.                         If you use a level of 1, it'll increase the
  191.                         brightness by 1/15; a level of 3 will increase
  192.                         by a level of 3/15, etc. If you've turned your
  193.                         lamp module off using off or fadeToOff, this
  194.                         command will turn your module on to full
  195.                         bright.*
  196.  
  197.             *************************************************************
  198.             * points to remember about these functions
  199.                 -    It's not my code making the CP290 act this way with
  200.                     dim and relativeBright so don't complain to me. I don't
  201.                     like it any more than you do!
  202.                 -    Although the function names aren't case sensitive,
  203.                     it'll just default to on if it doesn't understand your
  204.                     function due to misspelling..
  205.             *************************************************************
  206.                         
  207.             -h  Is used to set the base housecode of the X10 unit
  208.                 you wish to control. Base housecodes allowable are
  209.                 A through P. Upper or lower case are acceptable.
  210.                 Default is housecode A.
  211.                 
  212.             -u  Is used to set the unit number of the X10 unit you
  213.                 wish to control. Unit numbers are 1 through 16.
  214.                 Numbers over 16 are set to 16. The default on this
  215.                 option is unique. If you leave this option out, you
  216.                 will control all of the units on a particular
  217.                 housecode. In other words, you can turn on all
  218.                 units (lights, etc.) in housecode A by leaving
  219.                 all options out.
  220.                 
  221.             -p    Defines the serial port you wish to send the commands
  222.                 out of. This application is Comm ToolBox aware and
  223.                 you can use any of the registered Com ToolBox names.
  224.                 Most often, unless you've changed it, you'll be able
  225.                 to use "Modem Port" or "Printer Port". The default is
  226.                 for "Modem Port". If your option is not in the
  227.                 list of registered serial devices, an entry is made
  228.                 to the X10 Error File listing all available device
  229.                 names. Include one of the names from this list (don't
  230.                 forget the quotes if it's more than one word) and it
  231.                 should work just fine.
  232.  
  233.     —————————————————————————————————————————————————————————————————————
  234.  
  235. X10 Error File:
  236.  
  237.         In addition to writing to the error file when you've defined a wrong
  238.         serial port name, this application will inform you of a variety of
  239.         errors using this file. It will create this file automatically in
  240.         the cron directory (that's where this app must be put to work
  241.         correctly with cron) and will append errors to it as they occur. If
  242.         you're having trouble getting the X10 to respond, look in this
  243.         file. It'll tell you things like the serial port you've selected is
  244.         in use by another application and other errors. It's a text file
  245.         that's double-clickable by BBEdit. This file will only be created
  246.         when an error occurs. Once created, it will continue to append to
  247.         the error log. You may throw this file away at any time.
  248.         
  249.     —————————————————————————————————————————————————————————————————————
  250.  
  251. Examples of crontab entries:
  252.  
  253.         20 8 * * * nobody "cronX10" -l 8 -f dim -u 2 -p "Printer Port"
  254.         
  255.         This will turn on unit 2 in housecode A to a dim setting of 8
  256.         using the printer port for communications at 8:20am on every day
  257.         of every week of every year.
  258.         
  259.         0 0 * * * nobody "cronX10" -f off -h b // all units off in b
  260.         
  261.         This will turn off every unit in housecode B using the modem port
  262.         for communications at midnight on every day of every week of
  263.         every year.